package com.hucheng.activity.entity;

import com.hucheng.activity.dto.LuckPrizeDTO;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.sql.Timestamp;
import java.util.Date;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-10
 * @Description: 持久层数据
 **/
@Data
public class LuckPrizeDO {
    private Integer luckPrizeConfigId;
    private String luckPrizeConfigName;
    private Integer status;
    private Integer freeCount;
    private Date dateStart;
    private Date dateEnd;
    private Integer point;
    private Integer limitCount;
    private String luckPrizeRemark;
    private Integer isDel;
    private Timestamp dateCreated;
    private Timestamp dateUpdated;

    public static LuckPrizeDO buildLuckPrizeDO(final LuckPrizeDTO luckPrizeDTO) {
        if (luckPrizeDTO != null) {
            LuckPrizeDO luckPrizeDO = new LuckPrizeDO();
            Timestamp currentTime = new Timestamp(System.currentTimeMillis());
            if (StringUtils.isNotEmpty(luckPrizeDTO.getLuckPrizeConfigId()+"")) {
                luckPrizeDO.setLuckPrizeConfigId(luckPrizeDTO.getLuckPrizeConfigId());
                luckPrizeDO.setDateCreated(currentTime);
            }else{
                luckPrizeDO.setDateUpdated(currentTime);
            }
            luckPrizeDO.setLuckPrizeConfigName(luckPrizeDTO.getLuckPrizeConfigName());
            luckPrizeDO.setStatus(luckPrizeDTO.getStatus());
            luckPrizeDO.setFreeCount(luckPrizeDTO.getFreeCount());
            luckPrizeDO.setDateStart(luckPrizeDTO.getDateStart());
            luckPrizeDO.setDateEnd(luckPrizeDTO.getDateEnd());
            luckPrizeDO.setPoint(luckPrizeDTO.getPoint());
            luckPrizeDO.setLimitCount(luckPrizeDTO.getLimitCount());
            luckPrizeDO.setLuckPrizeRemark(luckPrizeDTO.getLuckPrizeRemark());
            luckPrizeDO.setIsDel(0);
            return luckPrizeDO;
        }
        return null;
    }
}
